import unittest
from io import StringIO
import sys


# 被测试函数
def max_num(num1, num2):
    if num1 > num2:
        print("第一个数字大")
    elif num1 < num2:
        print("第二个数字大")
    else:
        print("两个数字相等")


class TestMaxNum(unittest.TestCase):
    def capture_output(self, num1, num2):
        """捕获函数的打印输出"""
        captured_output = StringIO()
        sys.stdout = captured_output
        max_num(num1, num2)
        sys.stdout = sys.__stdout__
        return captured_output.getvalue().strip()

    # 基础比较测试
    def test_num1_greater(self):
        output = self.capture_output(10, 5)
        self.assertEqual(output, "第一个数字大")

    def test_num2_greater(self):
        output = self.capture_output(3, 9)
        self.assertEqual(output, "第二个数字大")

    def test_equal_numbers(self):
        output = self.capture_output(7, 7)
        self.assertEqual(output, "两个数字相等")

    # 负数和零测试
    def test_negative_num1_greater(self):
        output = self.capture_output(-5, -10)
        self.assertEqual(output, "第一个数字大")

    def test_negative_num2_greater(self):
        output = self.capture_output(-15, -8)
        self.assertEqual(output, "第二个数字大")

    def test_zero_positive(self):
        output = self.capture_output(0, 5)
        self.assertEqual(output, "第二个数字大")

    def test_zero_negative(self):
        output = self.capture_output(-3, 0)
        self.assertEqual(output, "第二个数字大")

    # 浮点数测试
    def test_float_num1_greater(self):
        output = self.capture_output(3.14, 3.0)
        self.assertEqual(output, "第一个数字大")

    def test_float_num2_greater(self):
        output = self.capture_output(2.71, 3.14)
        self.assertEqual(output, "第二个数字大")

    def test_float_equal(self):
        output = self.capture_output(5.5, 5.5)
        self.assertEqual(output, "两个数字相等")

    # 大数测试
    def test_large_numbers(self):
        output = self.capture_output(10 ** 100, 10 ** 100 - 1)
        self.assertEqual(output, "第一个数字大")


if __name__ == '__main__':
    unittest.main()